Repository navigation
OME-Zarr copies in 1024 x 1024 chunks; warn about stores too coarse for windows - #625
Merged
Merged
Conversation
…or windows convert --store ome-zarr (and the notebook's copy) wrote each plane as one chunk, so a windowed reader decoded the whole plane for every window and refused the first patch of a large slide after check had passed. - ome_zarr_copy: chunks 1 x ... x min(Y,1024) x min(X,1024), written block by block in place (edge chunks full size, zero-filled); no pyramid. - windows: smallest_window_memory, chunk_note (fix advice on refusals). - window_reader: WindowReader refuses at open an OME-Zarr whose chunks leave no window within the limit with its cache. - window_chunks (new): check_window_chunks -> warning chunks_too_large_for_windows, from check and run. - tests/test_ome_zarr_chunks.py; CHANGELOG, contract, user guide, AGENTS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug:
convert --store ome-zarr(and the notebook's /convert_experiment(..., store="ome-zarr")copies) wrote each plane as one chunk. A windowed route (fiberfeaturesrun.execution_route = "patch_window", viaRunInputs.window_reader) decodes a chunk whole for any window, so the first patch of a large converted slide was refused (WindowMemoryError) whilecheckpassed.By module:
ome_zarr_copy: chunks1 x ... x min(Y,1024) x min(X,1024)(CHUNK_SIDE,chunk_shape). Each plane is written as it is read, block by block within the memory limit (Plane.blocks()), each block's part of each chunk written in place (_PlaneChunks; edge chunks full size, zero =fill_value, as Zarr 2 stores them). A plane read in blocks is never held whole. Still uncompressed Zarr v2 / OME-NGFF 0.4, deterministic bytes.windows:smallest_window_memory(source, cache_bytes)(1-px window, header only) andchunk_note(...), appended to window memory refusals for OME-Zarr whose chunks leave no window within the limit (CHUNK_FIX: re-convert into a new folder, or rechunk to at most 1024 x 1024).window_reader:WindowReader(soRunInputs.window_reader) now refuses such a store at open (WindowMemoryError, same type as before, naming the chunks and the fix) instead of on the first window.window_chunks(new):check_window_chunks-> warningchunks_too_large_for_windows;window_chunk_need(path, mapping)for consumers' own checks. Called fromrun's header checks (with--memory-limit) and from CLIcheck(default 1 GiB;checkhas no limit option), and recorded in the check report.Decisions
windows.LEVEL), and a downsampling method would be a new, recorded choice. Not added.4 x chunk + chunk + header) above the limit. The reader's open refusal uses its actualcache_bytes.Byte / identity changes (CHANGELOG, Unreleased v0.10.1)
Copies of images larger than 1024 px along Y or X are new bytes (
0/.zarraychunks, chunk files0/<plane indices>/<row>/<col>), hence a differentcopy_sha256. Pixels,.zattrs, the rest of the record unchanged. Copies of planes <= 1024 x 1024 are byte-identical (verified against the base commit: 2 x 700 x 1000 identical; 1 x 1500 x 300 differs only in.zarrayand the split chunk). A re-conversion into a folder that already holds an old single-chunk copy reuses it (plan and content unchanged) — the advice says convert into a new folder.Notes for review
plane_over_memory_limitonly when over the plane limit); possible follow-up.convertcopies OME-Zarr sources byte for byte, so it cannot rechunk a user's own single-chunk store; the advice says to save it again with smaller chunks.checkcould callwindow_chunks.window_chunk_need/ open its reader during check to catch this with its own limit (follow-up in that repo).Tests
tests/test_ome_zarr_chunks.py(6): lazily-written tiled TIFF converted with an 8 MiB limit -> chunks[1,1024,1024], 3x3 full-size chunk files per channel, every pixel equal, tracemalloc peak < half a plane; windowed read across four chunks throughWindowReader+cache_planwithin 64 MiB, bitwise equal; same image in one chunk per plane -> warning, refused at reader open and byread_window, with the fix; CLIcheckon metadata-only 12000 x 12000 single-chunk stores warns (exit 0) and records it in the report.python -m pytest -q -n 4 -p no:cacheprovider, conda envmorphobricks-gate,PYTHONPATH=src): 9354 passed, 21 skipped, 3 failed. The 3 failures (test_code_identity::test_the_installed_preprocessing_is_identified_for_real,test_he_tissue_array::test_a_non_editable_install_states_verified_identities_for_real,test_he_tissue_mask::test_a_non_editable_install_is_verified_and_reused_for_real: "module not from this installation") fail identically on the base commit 6973070 in this setup:PYTHONPATH=srcshadows the env's installed wheel. Peak RSS of one process 1.7 GB.python tools/check.py --rulespasses;ruff check ./ruff format --check .pass.pip freezebefore and after identical (nothing installed).🤖 Generated with Claude Code